import Storage from "@/utils/storage";

const user = {
    state: {
        token: Storage.get("token") || null,
        userInfo: JSON.parse(Storage.get("userInfo")) || null
    },

    mutations: {
        setToken: (state, token) => {
            Storage.set("token", token);
            state.token = token;
        },
        setUserInfo: (state, userInfo) => {
            Storage.set("userInfo", JSON.stringify(userInfo));
            state.userInfo = userInfo;
        },
        userLoginOut: (state) => {
            Storage.clear();
            state.token = '';
            state.userInfo = null;
        }
    },

    actions: {
        
    }
};

export default user;